<?php
/**
 * @copyright
 * @author :
 * @version :
 * @name :
 * @todo:
*/
class VimuaAdvProvider extends CModule{
	public $saleoff = array();
	function init(){
		$cache_name = 'vimua_saleoff_news';
		$cache_time = 86400;
		
		if($this->saleoff = CSystem::$cachedata->get($cache_name))
		{}
		else
		{
			$this->saleoff = CTable('help')->fields('id,title,image')
										   ->select_all(EAnd(EEqual('category_id','SaleOff'),EEqual('display',1)),
														array('order_by'=>'sort_order ASC',
															  'items_per_page'=>10)
										   );
			
			foreach($this->saleoff as $key=>$val)
			{
				$count_title = explode(" ",$val['title']);
				$no = count($count_title);
				if(strlen($val['title'])>35)
				{	$str = '';
					if($no>=8)
					{
						for($i=0;$i<8;$i++)
							$str .= $count_title[$i].' ';
						$this->saleoff[$key]['title'] = $str.'..';
					}		
					else
					{
						$this->saleoff[$key]['title'] = $val['title'];
					}							
						
				}
				else
				{
					$this->saleoff[$key]['title'] = str_replace('\"','',$this->saleoff[$key]['title']);
				}	
			}
			
 			
			CSystem::$cachedata->set($cache_name,$this->saleoff, $cache_time);
		}	
										   
	}
	function draw(){
		CForm($this->path().'/layout.tpl')->parse(array(
			'number_items' => 5,
			'skin' => portal()->skin(),
			'saleoff' => $this->saleoff
		));
 	}
	function on_draw(){
 		return $this->draw();
 	}
}
?>
